package model;

import java.awt.Color;


public class World {
	private static World instance = null;
	private double gravity = 0.6;
	private Level level;
	private Player[] players = new Player[4];
	public int TILES_WIDTH = 32;
	public int TILES_HEIGHT = 32;
	public int WINDOW_WIDTH;
	public int WINDOW_HEIGHT;	
	public Color LEVEL_BACKGROUND_COLOR = new Color(9, 205, 218);

	
	/**
	 * Constructor. getInstance() should be used instead.
	 */
	private World(){ 
		/*for(int i = 0; i<4; i++){
			players.add(null);
		}*/
	}
	
	/**
	 * @return Instance of the world
	 */
	public static World getInstance(){
		if (instance == null)
			instance = new World();
		return instance;
	}
	
	/**
	 * @return List of players currently in the game
	 */
	public Player[] getPlayers(){
		return players;
	}
	
	/**
	 * @param players Players that should be playing the game
	 */
	/*public void setPlayers(List<Player> players){
		this.players = players; 
	}*/
	
	/**
	 * @param id The desired players id
	 * @return The desired player
	 */
	public Player getPlayer(int id){
		Player ret = null;
		for(Player p : players){
			if(p != null){
				if (p.getID() == id){
				ret = p;
				}
			}
		}
		return ret;
	}
	
	/*public void addPlayer(Player play){
		players.add(play);
	}*/
	
	public void setPlayer(int index, Player player){
		players[index] = player;
	}
	
	/**
	 * @return Current level
	 */
	public Level getLevel(){
		return level;
	}
	
	/**
	 * Exchange current level for a new one
	 * @param tiles
	 */
	public void setLevel(Level level){
		this.level = level;
	}

	public void setGravity(double gravity) {
		this.gravity = gravity;
	}

	public double getGravity() {
		return gravity;
	}

}
